import React, {Component} from 'react';
import {Button} from 'antd'

class Demo extends Component {
  render() {
    // let count = this.props.store.getState()
    let {count,person} = this.props
    return <div>
      <h1 style={{fontWeight: 900, fontSize:30}}>当前计数为{count}</h1>
      <select ref={s => this.select = s}>
        <option value={1}>1</option>
        <option value={2}>2</option>
        <option value={3}>3</option>
      </select>&nbsp;
      <Button type="primary" onClick={this.increment}>+</Button>&nbsp;
      <Button type="primary" onClick={this.subtraction}>-</Button>&nbsp;
      <Button type="primary" onClick={this.incrementOfOdd}>increment of odd</Button>&nbsp;
      <Button type="primary" onClick={this.incrementAsync}>increment async</Button>&nbsp;
    </div>
  }
  
  increment = () => {
    let {value} = this.select
    // this.props.store.dispatch(createIncrementAction(value*1))
    this.props.increment(value)
  }
  
  subtraction = () => {
    let {value} = this.select
    // this.props.store.dispatch(createSubtractionAction(value*1))
    this.props.subtraction(value)
  }
  
  incrementOfOdd = () => {
    let {value} = this.select
    let {count} = this.props
    if (count%2 === 1) {
      // this.props.store.dispatch(createIncrementAction(value*1))
      this.props.increment(value)
    }
  }
  
  incrementAsync = () => {
    let {value} = this.select
    // setTimeout(()=>{
    //   // this.props.store.dispatch(createIncrementAction(value*1))
    //   this.props.increment(value*1)
    // },1000)
    this.props.incrementAsync(value, 1000)
  }
}

export default Demo;
